package com.yoyo.advlitesdk;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private static final String DATA = "{\"app\":[{\"appId\":1,\"tPkg\":\"com.feng.waveview\",\"period\":5,\"duration\":10,\"liveTime\":2,\"allowDiscover\":false,\"isCloseApp\":true,\"isAutoInst\":false,\"appUrl\":\"https://yoyo-wallpaper.oss-cn-shenzhen.aliyuncs.com/wave1.0.apk\"}],\"pull\":[{\"type\":1,\"tPkg\":\"com.feng.waveview\",\"action\":\"will://link/testId\",\"inactivity\":0,\"frequency\":100,\"priority\":100,\"startTime\":1557042403000,\"endTime\":1559963077000,\"duringStartTime\":\"0000\",\"duringEndTime\":\"2400\",\"isBackHome\":true,\"whiteListId\":0,\"blackListId\":1},{\"type\":2,\"tPkg\":\"com.feng.waveview\",\"action\":\"\",\"inactivity\":0,\"frequency\":100,\"priority\":100,\"startTime\":1557042403000,\"endTime\":1559963077000,\"duringStartTime\":\"0000\",\"duringEndTime\":\"2400\",\"isBackHome\":true,\"whiteListId\":0,\"blackListId\":1},{\"type\":4,\"tPkg\":\"com.app.hubert.newbieguide\",\"action\":\"\",\"inactivity\":0,\"frequency\":100,\"priority\":100,\"startTime\":1557042403000,\"endTime\":1559963077000,\"duringStartTime\":\"0000\",\"duringEndTime\":\"2400\",\"isBackHome\":true,\"whiteListId\":0,\"blackListId\":1},{\"type\":1,\"tPkg\":\"com.dollkey.videodemo\",\"action\":\"will://link/testId\",\"inactivity\":0,\"frequency\":100,\"priority\":100,\"startTime\":1557042403000,\"endTime\":1559963077000,\"duringStartTime\":\"0000\",\"duringEndTime\":\"2400\",\"isBackHome\":true,\"whiteListId\":0,\"blackListId\":1},{\"type\":6,\"tPkg\":\"com.dollkey.videodemo\",\"action\":\"will://link/testId\",\"inactivity\":0,\"frequency\":100,\"priority\":100,\"startTime\":1557042403000,\"endTime\":1559963077000,\"duringStartTime\":\"0000\",\"duringEndTime\":\"2400\",\"isBackHome\":true,\"whiteListId\":0,\"blackListId\":1}],\"rule\":[{\"ruleId\":1,\"pkg\":[\"com.dollkey.packagemanager\",\"com.yoyo.advlitesdk\"],\"model\":[\"HuaWei\",\"XiaoMi\"],\"channel\":[\"HuaWei\",\"XiaoMi\"],\"city\":[\"ShenZhen\",\"ShangHai\"],\"imei\":[\"000000000000000\"]},{\"ruleId\":2,\"pkg\":[\"com.dollkey.packagemanager\",\"com.yoyo.advlitesdk\"],\"model\":[\"HuaWei\",\"XiaoMi\"],\"channel\":[\"HuaWei\",\"XiaoMi\"],\"city\":[\"ShenZhen\",\"ShangHai\"],\"imei\":[\"000000000000000\"]}],\"config\":{\"autoDelayTime\":30,\"interval\":1},\"monitorTime\":[{\"hour\":0,\"minute\":5,\"type\":1},{\"hour\":23,\"minute\":50,\"type\":2}]}";
    private static final String TAG = "MainActivity";

    private final String SERVICE_NAME = "com.yoyo.yyadsdk.main.KernelService";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_advert_main);
//        AdSDKManager.getInstance().initTestData(null);
//        startAdvertService();
//        Intent intentHome = new Intent(Intent.ACTION_MAIN);
//        intentHome.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//        intentHome.addCategory(Intent.CATEGORY_HOME);
//        startActivity(intentHome);
//        startAdvertService();
        finish();
    }

    private void startAdvertService() {
        try {
            Intent intent = new Intent();
            ComponentName component = new ComponentName(this.getPackageName(), SERVICE_NAME);
            intent.setComponent(component);
            startService(intent);
        } catch (Exception e) {
            // TODO Auto-generated catch block
//            if (AdvertFeature.FEATURE_LOG_ENABLE) e.printStackTrace();
        }
    }


    public void toSetting(View view) {
//        startActivity(new Intent(MainActivity.this, SettingsActivity.class));
    }
}
